﻿Imports System.Web.UI
Imports SISSAT.BusinessLayer.DomainModels
Imports SISSAT.Administration.Views

Namespace Pages.Administration
    Public Class Subjects
        Inherits Page
        Implements ISubjectView

#Region "Properties"

        Private Property Presenter As SubjectPresenter

#End Region

#Region "ISubjectView Members"

        Public WriteOnly Property RepeaterDataSource As IEnumerable(Of Subject) Implements ISubjectView.RepeaterDataSource
            Set(value As IEnumerable(Of Subject))
                SubjectRepeater.DataSource = value
                SubjectRepeater.DataBind()
            End Set
        End Property

        Public ReadOnly Property SubjectId As Integer Implements ISubjectView.SubjectId
            Get
                Dim id As Integer = 0
                Dim sid As String = HttpContext.Current.Request.QueryString("sid")
                If Not String.IsNullOrEmpty(sid) AndAlso Integer.TryParse(sid, id) Then
                    ' No logic
                ElseIf String.Compare(sid, "new", True) = 0 Then
                    id = 1
                End If

                Return id
            End Get
        End Property

        Public Event OnInitialization() Implements ISubjectView.OnInitialization

#End Region

#Region "Events"

        Private Sub PageInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            If Me.SubjectId > 0 Then
                SubjectViews.ActiveViewIndex = 1
            End If

            Presenter = New SubjectPresenter(Me)
            RaiseEvent OnInitialization()
        End Sub

#End Region

    End Class
End Namespace
